using System.Collections.Generic;
using Sedge.Core.Configuration.Report;

namespace Sedge.Core.Configuration
{
	public class ReportableObject
	{
		#region Private fields
		
		private readonly Dictionary<string, string> _properties = new Dictionary<string, string>();
		private static readonly Dictionary<string, string> _globalProperties = new Dictionary<string, string>();
		private readonly IList<Group> _groups = new List<Group>();

		#endregion // Private fields

		#region Properties
		
		public string Name { get; set; }
		public string Caption { get; set; }
		
		public Dictionary<string, string> Properties
		{
			get { return _properties; }
		}

		public static Dictionary<string, string> GlobalProperties
		{
			get { return _globalProperties; }
		}

		public IList<Group> Groups
		{
			get { return _groups; }
		}

		public ReportableObject Parent { get; set; }

        #endregion // Properties

		#region Constructors

        #endregion // Constructors

		#region Private methods


		#endregion // Private methods

		#region Public methods

		public void AddProperty(string name, string value)
		{
			_properties[name] = value;
		}

		public string GetPropertyValue(string key)
		{
			if (_properties.ContainsKey(key))
				return _properties[key];

			if (Parent != null)
				return Parent.GetPropertyValue(key);

			if (_globalProperties.ContainsKey(key))
					return _globalProperties[key];

			return null;
		}

		#endregion //Public methods
	}
}